import core.util.Iterator;

class ArrayList {

	this.ArrayList = function(elements) {
		this.elements = elements || [];
	}

	this.add = function(element) {
		this.elements.push(element);
	}

	this.indexOf = function(element) {
		for (var i = 0, n = this.elements.length; i < n; ++i) {
			if (element === this.elements[i]) {
				return i;
			}
		}
		return -1;
	}

	this.get = function(i) {
		return this.elements[i];
	}

	this.size = function() {
		return this.elements.length;
	}

	this.clear = function() {
		delete this.elements;
		this.elements = [];
	}

	this.iterator = function() {
		return new Iterator(this.elements);
	}

	this.toArray = function() {
		return this.elements;
	}
}
